package com.jcp.controller;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.RestController;

import com.jcp.entity.Park;
import com.jcp.entity.Stats;
import com.jcp.service.ParkService;
import com.jcp.service.StatsService;

@Controller
public class StatsController {
	
	
	@Autowired
	private StatsService statsService;
	@Autowired
	private ParkService parkService;
	
	@RequestMapping(value="selStatsMessage", method = RequestMethod.GET)
	@ResponseBody
	public List<Stats> selStatsMessage(){
		List<Stats> list=statsService.selectRecord();
		//List<Park> park=parkService.selectPark();
		/*model.addAttribute("stats", list);*/
		//model.addAttribute("park", park.get(0));
		//list.forEach(s->System.out.println(s.getDays()));
		return list;
	}
	@RequestMapping(value="selRecordOut", method = RequestMethod.GET)
	@ResponseBody
	public List<Stats> selRecordOut(){
		List<Stats> listOut=statsService.selectRecordOut();
		listOut.forEach(s->System.out.println(s));
		return listOut;
	}
	
	@GetMapping(value="selParkMessage")
	public String selParkMessage(Model model) {
		List<Park> park=parkService.selectPark();
		model.addAttribute("park", park.get(0));
		return "forward:cheliang-listStats.jsp";
	}
	
	@RequestMapping(value="selParment", method = RequestMethod.GET)
	@ResponseBody
	public List<Stats> selParment(){
		List<Stats> list1=statsService.selectParment();
		list1.forEach(s->System.out.println(s));
		return list1;
	}
	

}
